import { ref } from "vue";

const useRequest = (asyncFunc) => {
  const loading  = ref(false);

  const runAsync = async (params) => {
    loading.value = true;
    const res = await asyncFunc(params);
    loading.value = false;
    return res;
  }

  return {
    loading,
    runAsync
  }
}

export default useRequest;